package leading;

import java.util.Map;
import java.util.Set;

public class MapToJson {
	public static void main(String[] args) {
		
	}
	
	private String MapToJSON(Map<String,Object> map){
		String tJson = null;
		if(map.isEmpty()){
			return "{}";
		}
		StringBuffer sb = new StringBuffer();
		sb.append("{");
		Set<String> set = map.keySet();
		for(String key : set){
			Object value = map.get(key);
			sb.append('"');
			sb.append(key);
			sb.append('"');
			sb.append(':');
		//	sb.append(toJSON(value));
			sb.append(',');
		}
		//将最后的‘,’变为'}'       sb.setCharAt(sb.lenth()-1,"}");
		sb.toString().substring(0, sb.length()-1);
		tJson = sb + "}";
		
		return tJson;
	}
	
	
}
